{% extends 'base.html' %}

{% block body %}

<div class="container col-lg-8 col-md-offset-2">

    <div class="panel panel-success ">
      <div class="panel-heading">
        <h3 class="panel-title">学生活动丨报名</h3>
      </div>
      <div class="panel-body">
      {% if status != 1 %}
        <span style="color: red;">{{ customer_form.errors }}</span>
        <form class="form-horizontal" role="form" method="post" onsubmit="return RegisterFormCheck()">{% csrf_token %}
          {% for field in customer_form %}
              <div class="form-group">
                <label  class="col-sm-2 control-label">{{ field.label }}</label>
                <div class="col-sm-9">
                  {{ field }}
                </div>
              </div>
          {% endfor %}
      <hr/>
        <div class="form-group">
                <label  class="col-sm-2 control-label">所报活动</label>
                <div class="col-sm-9">
                  {{ enroll_obj.enrolled_class }}
                </div>
        </div>
        <div class="form-group">
                <label  class="col-sm-2 control-label">开始日期</label>
                <div class="col-sm-9">
                  {{ enroll_obj.enrolled_class.start_date }}
                </div>
        </div>
        <div class="form-group " style="text-align: center;color: #d58512">
                <div class="col-sm-12">
                    <input type="checkbox" name="contract_agreed" > 我保证遵守主办方的各项规定，积极参与，安全第一！
                </div>
        </div>
        <div class="text-center">
                    <input type="submit" class="btn btn-info " value="提交">

        </div>
      </form>
      {% else %}
        <h2>感谢，报名表已提交，您的申请将很快被审核，感谢您对该活动的支持！</h2>
      {% endif %}
      </div>

    <hr>
    {% if  status != 1 %}
{#    <p>请上传相关文件</p>#}
        <form id="filedropzone" method="post" action="{{ request.path }}" class="dropzone dz-clickable" >{% csrf_token %}
            <div class="dz-default dz-message">
                <div class="dz-icon icon-wrap icon-circle icon-wrap-md">
                    <i class="fa fa-cloud-upload fa-3x"></i>
                </div>
                <div>
                    <p class="dz-text">请把要上传的文件拖放到这里</p>
                    <p class="text-muted">最好打包成.zip上传格式</p>
                </div>
            </div>

        </form>
    {% endif %}

    </div>

</div>

{% endblock %}

{% block bottom-js %}
<script>

        $(document).ready(function () {
         Dropzone.options.filedropzone = {
          url:"{{ request.path }}",
          paramName: "file", // The name that will be used to transfer the file
          maxFilesize: 1, // MB,
          addRemoveLinks:true,
          maxFiles:5,
          uploadMultiple:true,
          accept: function(file, done) {
            if (file.name == "justinbieber.jpg") {
              done("Naha, you don't.");
            }
            else { done(); }
          }
        };




      myDropzone.on("success", function(file,response) {
          /* Maybe display some more file information on your page */
          console.log('filex upload done...', response);
      } )

    })
        function RegisterFormCheck() {
{#        if (myDropzone.files.length <2){#}
{#            alert("必须至少上传2张图片!")#}
{#            return false;#}
{#        }#}

        if ($("form :checkbox").prop('checked') ){
            $("form").find("[disabled]").removeAttr("disabled");

            return true;
        }else {
            alert("必须同意条款");
            return false;
        }

    }
</script>

{% endblock %}